package com.rbac.mapper.test;

import com.rbac.pojo.Employee;
import com.rbac.pojo.Permission;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LoginMapper2 {

    @Select("select * from employee where username = #{username}")
    Employee getUserbyName(String username);

    @Select("select * from permission where level = #{level}")
    List<Permission> getRouter(Integer level);

    @Insert("insert into Employee (username, password) values (#{username}, #{password})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int registerUser(Employee employee);

    @Insert("insert into user_role (user_id, role_id) values (#{userId}, 6)")
    void setUserDefaultRole(Integer userId);
}
